package com.bhs.sansong.ui.other;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.bhs.sansong.R;
import com.bhs.sansong.base.BaseActivity;
import com.bhs.sansong.utils.SharedPreferencesUtils;
import com.bumptech.glide.Glide;

public class ConfigActivity extends BaseActivity {
    private RadioGroup mRgUrl;
    private RadioButton mRbOfficial;
    private RadioButton mRbTest;
    private ImageView mIvFace;

    @Override
    public int initLayout() {
        return R.layout.activity_config;
    }

    @Override
    public void initView() {

        mRgUrl = findViewById(R.id.rg_url);
        mRbOfficial = findViewById(R.id.rb_official);
        mRbTest = findViewById(R.id.rb_test);
        String urlType = SharedPreferencesUtils.getString(mActivity, "urlType");
        mRbOfficial.setChecked(urlType.equals("1"));
        mRbTest.setChecked(urlType.equals("2"));
        mIvFace = findViewById(R.id.iv_face);
        String url = "https://sansong20.oss-cn-shanghai.aliyuncs.com/gobalsansong/upload/other/2023/07/03/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20230713095200.jpg";
        Glide.with(mActivity).load(url).into(mIvFace);
    }

    @Override
    public void initData() {
        mRgUrl.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.rb_official) {
                    SharedPreferencesUtils.saveString(mActivity, "urlType", "1");
                } else {
                    SharedPreferencesUtils.saveString(mActivity, "urlType", "2");
                }
            }
        });
    }
}